package com.example.demo.Controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.demo.bean.customer;
import com.example.demo.service.customerService;
import com.example.demo.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags="客户管理")
@RequestMapping("/customer")
public class customerController {
    @Autowired
    private  customerService customerService;
    @PostMapping("/Insertcustomer")
    @ApiOperation(value = "增加客户信息", notes = "插入客户信息")
    public int Insertcustomer(customer customer){
        customerService.Insertcustomer(customer);
        return 1;
    }

    @PostMapping("/Deletecustomer")
    @ApiOperation(value = "删除客户信息", notes = "根据客户Id")
    public int Deletecustomer(@RequestParam("customerid") Integer customerid){
        customerService.Deletecustomer(customerid);
        return 1;
    }

    /**
     * 通过实体修改数据
     * @param
     * @return
     */
    @PostMapping("/Updatecustomer")
    @ApiOperation(value = "更新客户信息", notes = "根据Id修改客户信息")
    public int Updatecustomer(customer customer){
        customerService.Updatecustomer(customer);
        return 1;
    }

    /**
     * 查询所有数据
     * @return
     */
    @ResponseBody
    @ApiOperation(value = "获取客户信息列表", notes = "获取所有客户信息")
    @PostMapping("/ShowAllcustomer")
    public List<customer> ShowAllcustomer(){
        return  customerService.ShowAllcustomer();
    }

}
